//
//  ViewController.m
//  06-UINavigationController
//
//  Created by 李昊林 on 16/7/21.
//  Copyright © 2016年 李昊林. All rights reserved.
//

#import "ViewController.h"
#import "PushViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    //先设置NavigationBar属性
    //1.标题，告诉别人，我这个视图是干啥用的
    self.title = @"我是标题，嘿嘿嘿";
    self.navigationItem.title = @"XXXX,嘿嘿嘿嘿";
    //2.titleView标题视图
    UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:@[@"韩旭",@"王煌"]];
    segment.frame = CGRectMake(0, 0, 150, 44);
    //修改标题视图的xy，对标图本身没有影响
    self.navigationItem.titleView = segment;
    //3.leftBarButtonItem
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:(UIBarButtonItemStylePlain) target:self action:@selector(comeBack:)];
    //4.rightBarButtonItem
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(add:)];
    //5.
//    UIBarButtonItem *barButtonItemTitle = [[UIBarButtonItem alloc] initWithTitle:@"XXX" style:(UIBarButtonItemStylePlain) target:self action:@selector(comeBack:)];
//    
//    UIBarButtonItem *barButtonItemSystemItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(add:)];
//
//
//    self.navigationItem.leftBarButtonItem = @[barButtonItemTitle,barButtonItemSystemItem];

    //7.隐藏个NavigationBar yes隐藏 NO不隐藏 默认为NO
    //两句等效的
    self.navigationController.navigationBarHidden = NO;
    self.navigationController.navigationBar.hidden = NO;
    //8.navigationBar背景样式 默认为Default
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    //9.
    self.navigationController.navigationBar.backgroundColor = [UIColor redColor];
    //10.barTintColor
    self.navigationController.navigationBar.barTintColor = [UIColor redColor];
    //11.tintcolor bar上元素的颜色
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    //12.
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(0, 0, 200, 200);
    button.backgroundColor = [UIColor blueColor];
    [self.view addSubview:button];
    [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    //设置为YES时，self.view坐标系从原点开始
    //设置为NO时候，self.view坐标系从navBar开始
//    self.navigationController.navigationBar.translucent = NO;
  //13.改变坐标系。与translucent为NO时效果一样
    self.edgesForExtendedLayout = UIRectEdgeNone;
}
//页面跳转相关
//1.push 入栈
//2.pop 出栈
//3.viewController存放navgationController里所有的控制器
//4.topViewController 栈顶视图控制器
//5.visibleViewController 可见视图控制器（）


- (void)buttonClicked:(UIButton *)button {
    //视图控制器入栈
    [self.navigationController pushViewController:[[PushViewController alloc]init] animated:YES];
}

- (void)comeBack:(UIBarButtonItem*)barButtonItem {
    NSLog(@"返回");
}

- (void)add:(UIBarButtonItem *)barButtonItem {
    NSLog(@"添加");
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
